//============================================================================
// Name        : wings.cpp
// Author      : Benedikt Bovelette / Ingmar Hartung
// Version     :
// Copyright   : (c) 2012
// Description :
//============================================================================
#include "Header/wings.h"

static float yypoz = 0;

void animate() {
// We increment the rotation angle for the triangle, and if it went over 360 we wrap it back to 0
	yypoz += 10.0;
	if (yypoz == 360)
		yypoz = 0;

// Normally openGL doesn't continuously draw frames. It puts one in place and waits for you to tell him what to do next.
	// Calling glutPostRedisplay() forces a redraw with the new angle
	glutPostRedisplay();

}

void DrawMark(float angle) {
	GLUquadricObj* cylSphere;
	cylSphere = gluNewQuadric();
	glRotatef(angle,0, 0, 1);
	glTranslatef(0.0, 0.7, 0.0);
	glColor3f(.4, .0, .0);
	glScalef(0.3, 0.7, 0.2);
	initMaterial(5);
	gluSphere(cylSphere, .15, 100, 100);
}

void DrawWings() {
	GLUquadricObj* cylSphere;
	cylSphere = gluNewQuadric();

	glPushMatrix();
	{
		glTranslatef(-0.13, 0.01, -0.385);
		glPushMatrix();
		{
			GLUquadricObj* cylSphere;
			cylSphere = gluNewQuadric();
			glTranslatef(1.2, 0.01, 0.5);
			glRotatef(-75, 0., 1.0, 0.);
			glRotatef(-yypoz, 0, 0, 1);
			gluCylinder(cylSphere, 0.0, 0.0, 0.0, 100, 100);

			//Leichtgrau
			glPushMatrix();
			{
				glRotatef(0, 1, 0, 0);
				glTranslatef(0.0, 0.4, 0);
				glColor3f(.6, .6, .6);
				glScalef(0.4, 2.6, 0.2);
				initMaterial(1);
				gluSphere(cylSphere, .15, 100, 100);

			}
			glPopMatrix();

			glPushMatrix();
			{
				DrawMark(0.0);
			}
			glPopMatrix();
//			//Leichtgrau
			glPushMatrix();
			{
				glRotatef(60, 0, 0, 1);
				glTranslatef(0.0, -0.35, 0);
				glColor3f(.6, .6, .6);
				glScalef(0.4, 2.6, 0.2);
				initMaterial(1);
				gluSphere(cylSphere, .15, 100, 100);
			}
			glPopMatrix();
			glPushMatrix();
			{
				DrawMark(240.0);
			}
			glPopMatrix();

//			//Leichtgrau
			glPushMatrix();
			{
				glRotatef(-60, 0, 0, 1);
				glTranslatef(0.0, -0.35, 0);
				glColor3f(.6, .6, .6);
				glScalef(0.4, 2.6, 0.2);
				initMaterial(4);
				gluSphere(cylSphere, .15, 100, 100);
			}
			glPopMatrix();
			glPushMatrix();
			{
				DrawMark(120.0);
			}
			glPopMatrix();
		}
		glPopMatrix();
		Sleep(5);
	}
	glPopMatrix();

}
